package com.heartunderblade.rpc;

import com.heartunderblade.rpc.bootstrap.ConsumerBootstrap;
import com.heartunderblade.rpc.factory.ServiceProxyFactory;
import com.heartunderblade.rpc.pojo.User;
import com.heartunderblade.rpc.service.UserService;

/**
 * 消费者调用请求
 */
public class CoreConsumerSampleByBootstrap {
    public static void main(String[] args) {
        // 服务消费者初始化
        ConsumerBootstrap.init();

        // 动态代理模式
        UserService userService = ServiceProxyFactory.getProxy(UserService.class);
        User user = new User("noob");

        // 单次调用
        User newUser = userService.getUser(user);
        if(newUser != null) {
            System.out.println(newUser.getName());
        }else {
            System.out.println("user == null");
        }
    }
}
